#include "Q4_5.h"

void Invert(int input[], int num_element)
{
	int middle_index = num_element/2;
	for(int i=0; i<middle_index; i++)
	{
		int temp = input[i];
		input[i] = input[num_element-i-1];
		input[num_element-i-1] = temp;
	}
}

void Invert(int input[], int num_element, int output[])
{
	for(int i=num_element-1; i>=0; i--)
	{
		output[num_element - 1 - i] = input[i];
	}
}

void q4_5_run()
{
	printf("Q4.5\n");

	int a[6] = {1, 5, 2, 3, 6, 4};
	for(int i=0; i<6; i++)
	{
		printf("A[%d]: %d\n", i, a[i]);
	}
	printf("Invert input!\n");
	Invert(a, 6);
	for(int i=0; i<6; i++)
	{
		printf("A[%d]: %d\n", i, a[i]);
	}

	printf("Generate output from invert input!\n");
	int b[6];
	Invert(a,6,b);
	for(int i=0; i<6; i++)
	{
		printf("A[%d]: %d\n", i, b[i]);
	}
}